# -*- coding: utf-8 -*-
"""
# --------------------------------------------------------
# @Author : Pan
# @E-mail : 
# @Date   : 2025-11-03 15:28:15
# @Brief  :
# --------------------------------------------------------
"""
import os
import base64
from pybaseutils import http_utils, json_utils, image_utils, base64_utils

# -*- coding: utf-8 -*-
"""
# --------------------------------------------------------
# @Author : Pan
# @E-mail : 
# @Date   : 2025-09-28 19:25:01
# @Brief  : https://github.com/OpenSQZ/MiniCPM-V-CookBook/blob/main/deployment/vllm/minicpm-v4_5_vllm_zh.md
# --------------------------------------------------------
"""
from openai import OpenAI
from pybaseutils import http_utils, json_utils, image_utils, base64_utils

# API 配置
model = ""
base_url = "http://192.168.68.102:40000/v1"  # 真实地址 base_url + /chat/completions
api_key = "token-abc123"  # API 密钥需与启动服务时设置的密钥保持一致
image_file = "../data/image1.jpg"
video_file = "../data/video2.mp4"
image = image_utils.read_image(image_file, use_rgb=True)
messages = [{
    "role": "user",
    "content": [
        {"type": "text", "text": "请描述这张图片"},
        {"type": "image", "image": image},
    ],
    "reqid": "123456"
}]

client = OpenAI(api_key=api_key, base_url=base_url)
messages = base64_utils.serialization(messages, prefix="data:image/jpeg;base64,", use_rgb=True)
response = client.chat.completions.create(model=model, messages=messages, extra_body={"stop_token_ids": [1, 151645]})
print("response:", response.choices[0].message.content)
print("response:", response.choices[0].message.content[0]['text'])
